//
//  NewsTableViewCell.m
//  Menu
//
//  Created by Lynn-Shin on 15/7/3.
//  Copyright (c) 2015年 lijiangang. All rights reserved.
//

#import "NewsTableViewCell.h"

@implementation NewsTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews{
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10*WIDTH, 10*HEIGHT, 180*WIDTH, 40*HEIGHT)];
//    self.titleLabel.backgroundColor = [UIColor lightGrayColor];
//    self.titleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:self.titleLabel];
    [self.titleLabel release];
    
    self.detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(10*WIDTH, 45*HEIGHT, 200*WIDTH, 50*HEIGHT)];
//    self.detailLabel.backgroundColor = [UIColor lightGrayColor];
    self.detailLabel.font = [UIFont systemFontOfSize:15];
    self.detailLabel.numberOfLines = 2;
    self.detailLabel.textColor = [UIColor grayColor];
    [self addSubview:self.detailLabel];
    [self.detailLabel release];
    
    self.myImage = [[UIImageView alloc] initWithFrame:CGRectMake(220*WIDTH, 5*HEIGHT, 150*WIDTH, 100*HEIGHT)];
//    self.myImage.backgroundColor = [UIColor redColor];
    [self addSubview:self.myImage];
    [self.myImage release];
}

-(void)setNewsList:(NewsListModel *)newsList{
    
    if (_newsList != newsList) {
        
        [_newsList release];
        _newsList = [newsList retain];
    }
    
    self.titleLabel.text = newsList.name;
    self.detailLabel.text = newsList.content;
    
    [self.myImage sd_setImageWithURL:[NSURL URLWithString:newsList.titleImageFile] placeholderImage:[UIImage imageNamed:@"zhanwei.png"]];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
